<script type="text/javascript">
	// Enquire about products, the click
	jQuery("#email_colleague_form").submit(function(e){ 
		// post enquiry to controller
		jQuery.ajax({
			type: 'POST',
			url: '<?=site_url('email_colleague/index/'.$type.'/'.$id)?>',
			data: jQuery("#email_colleague_form").serialize(),
			success: function(response){ 
				// show response
				jQuery('#email_colleague_form').html(response);			
			}
		});
		
		return false;
	});
</script>


<form id="email_colleague_form" method="post">

	<h1>Email a colleague</h1>
    
    <div class="preview">
        
        <? 	
        switch ($type){
            
            case 'news':
            case 'publicity':
            case 'glossary':
            case 'faq':
            case 'articles':
            case 'exhibitions':
            case 'career_opportunities':
            case 'products':
            case 'portfolio':
        ?>
        
            <div class="contain">
         
           
                <? if (isset($image)) { ?>
                    <img height="66" border="0" width="106" alt="" src="<?=$image?>">
                <? } ?>
                
                <? if (isset($date)) { ?>
                    <p class="date"><?=format_date($date)?><? if (isset($date2)) echo " - ".$date2 ?></p>
                <? } ?>
                
                <p>
                  <strong>
                      <?=$title?>
                  </strong>
                </p>
        
                <p>
                  <?=$text?>
                </p>
        
            </div>
        
        <? 	
            break;
            
            case 'wishlist':
        ?>
        
        <?
			$i=0;
            foreach($lists as $wishlist) 
            {
        ?>            
            <!-- FIX ME: Move this class to the stylesheet, there should be no inline styling here -->
            <div class="headercontain" <? if ($i==0) {?> style="margin-top:-2em;" <? } ?>>
                <p><?=$wishlist["name"]?></p>
            </div>    
            <? $i++; ?>

            <div class="contain">
            
                <? if (isset($wishlist['items']) && !empty($wishlist['items'])) { ?>
                   
                    <p> 
                    <? 
                    $max_items = 10;
					if (count($lists)>1) {
						$max_items = ceil($max_items/(count($lists)));
						if ($max_items<2) $max_items = 2;
					}
                    $more_items = 0;
                    foreach($wishlist['items'] as $product) {             
                        if ($max_items>=1){ ?>
                            <?=$product["title"]?><br />
                        <? } else { 
                            $more_items++;
                        }
                        $max_items--;
                    } 
                    ?>
                        
                    <?
                    if ($more_items==1) {
                    ?>
                        <?=$product["title"]?><br />
                    <? 
					} else if ($more_items>1) {
                    ?>
                        ...<?=$more_items?> other products
                    <? } ?>                
                    </p>
                    
                <? } else { ?>
                    <p>
                        <strong>
                        	<?=$this->lang->line('WishlistEmpty');?>
                        </strong>
                    </p>
                <? } ?>        
                
            </div>            
            
        <? 
            }
        ?>    
        
        <?	
            break;
        }
        ?>
    
    
    </div>
    
    
    
    
    
    
    
    <label>Your email</label>
    <input type="text" class="inputbox" name="sender_email" value="<?=set_value('sender_email', $sender_email) ?>" />
    <label>Recipient's email</label>
    <input type="text" class="inputbox" name="email" value="<?=set_value('email'); ?>" />
    <label>Your message</label>
    <textarea class="inputbox" name="message"><?=set_value('message'); ?></textarea>
    <div class="bottom">
        <? if($this->input->post("id") !== FALSE){ echo validation_errors(); } ?>
        <input type="hidden" name="type" value="<?=$type?>" />
        <input type="hidden" name="id" value="<?=$id?>" />
        <input type="hidden" name="token" id="token" value="<?=$token?>" />
        <input type="submit" class="button first" value="SEND" />
        <a class="button cancel" href="#">CANCEL</a>
    </div>



</form>